#include <iostream>

using namespace std;

int main() {
    //使用指针创建二维数组
    int (*p2)[3] = new int [5] [3];  //[5]被(*p2)所代替
    p2[3] [2] = 998;
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 3; ++j) {
            cout << p2[i] [j] <<','; //p2[i] [j]等同于*(*(p2+i) + j)
        }
        cout << endl;
    }


  /*  int arrays[] {15, 23, 30, 40, 50};
    int * ptr_start = arrays;  //指向第一个元素
    int * ptr_end = arrays + 4; //指向最后一个元素
    int temp;
    while (ptr_start != ptr_end){
        temp = *ptr_start;
        *ptr_start = *ptr_end;
        *ptr_end = temp;
        ptr_start++;
        ptr_end--;
    }
    for (int i = 0; i < 5; ++i) {
        cout << arrays[i] << endl;
    }*/


   /* int arrays[] {15, 23, 30, 40, 50};
    int* p_arrays = arrays;
    for (int i = 0; i < 5; ++i) {
        cout << *(p_arrays+i) << endl;
    }*/


    /*int num[5];
    int* nums = new int [5];
    cout << sizeof(num) << '\t' << sizeof(nums) << endl;*/



  /*  //数组
    double score[] {11, 22, 33, 44, 55};
    double * ptr_score = score;
    cout << sizeof(score) << '\t' << sizeof(ptr_score) << endl;*/


   /* //引用
    int num = 108;
    int& rel_num = num;
    rel_num = 118;
    cout << &num << '\t' << &rel_num << '\t' << rel_num << endl;
    //等同于
    int num1 = 108;
    int* rel_num1 = &num;
    *rel_num1 = 118;
    cout << &num1 << '\t' << rel_num1 << '\t' << *rel_num1 << endl;*/


   /* //指针
    double num = 3.14;
    double * ptr_num1 = &num;
    void * ptr_num2 = &num;
    cout << boolalpha;
    cout << (ptr_num1 == ptr_num2) << endl;*/


    /* //空指针
    double * ptr_double;  为一个野指针
    double * ptr_double = nullptr;
    cout << ptr_double << endl;*/


    /*char ch = 'a';
    char * ptr_ch = &ch; // 系统会自动把char型指针当成字符串来打印
    cout << (void *)ptr_ch << '\t' << *ptr_ch << endl;
    // void *表示任意类型的指针*/


    /*double num = 1024.5;
    //声明一个指针，指向num变量
    double* ptr_num = &num;
    cout << "ptr_num的值：" << ptr_num << endl;
    cout << "ptr_num指向空间的值：" << *ptr_num << endl;
    return 0;*/
}
